package com.imooc.ecommerce.config;

import brave.sampler.RateLimitingSampler;
import brave.sampler.Sampler;
import org.springframework.cloud.sleuth.sampler.ProbabilityBasedSampler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * <p>使用配置的方式设定抽样率
 *
 * @author Yaxi.Zhang
 * @since 2022/11/10 18:42
 */
@Configuration
public class SamplerConfig {
    /**
     * <p>限速采集
     */
    @Bean
    public Sampler rateLimitingSampler() {
        return RateLimitingSampler.create(100);
    }

    // /**
    //  * <p>概率采集, 默认的采样策略, 默认值是 0.1
    //  */
    // @Bean
    // public Sampler probabilityBasedSampler() {
    //     return ProbabilityBasedSampler.create(0.5f);
    // }

}
